#! -*- coding=utf-8 -*-
import xlrd
import os
import xlwt

 
data = xlrd.open_workbook("D:/chuangxin/应城这边要求/李主任文件/敏感信息/2022-10-14/网站错敏信息_20221014111608.xlsx")
common_path= 'D:/chuangxin/应城这边要求/李主任文件/敏感信息/2022-10-14/'
st = data.sheet_by_index(0)
#读取一整列的数据
lie = [str(st.cell_value(i, 18)) for i in range(1, st.nrows)]
#读取一整行的数据
#hang = [str(st.cell_value(3, i)) for i in range(0, st.ncols)]

#写



p=0

#去重list
site_name = list(set(lie))
print(site_name)
for path in site_name:
    folder = os.path.exists(common_path+path)
    if not folder:
        os.mkdir(common_path+path)
    else:
        print('创建失败')
    workbook = xlwt.Workbook()
    workSheet = workbook.add_sheet("栏目标题外链",cell_overwrite_ok=True)
    workSheet.write(0,0,"错敏词")
    workSheet.write(0,1,"推荐修改")
    workSheet.write(0,2,"所在上下文")
    
    workSheet.write(0,3,"所在文章")
    workSheet.write(0,4,"快照")
    workSheet.write(0,5,"所在文章链接")
    
    workSheet.write(0,6,"网站名称")
    workSheet.write(0,7,"网站标识码")
    workSheet.write(0,8,"地区")
    
    workSheet.write(0,9,"层级")
    workSheet.write(0,10,"机构")
    workSheet.write(0,11,"问题类型")
    
    workSheet.write(0,12,"问题级别")
    workSheet.write(0,13,"内容类型")
    workSheet.write(0,14,"网站地址")
    
    workSheet.write(0,15,"文章来源")
    workSheet.write(0,16,"作者")
    workSheet.write(0,17,"发布单位")
    
    workSheet.write(0,18,"检测时间")
    workSheet.write(0,19,"发布时间")
    workSheet.write(0,20,"父页面地址")
    
    for row_index in range(1,st.nrows):
        if st.cell(row_index,0).value == path:
            p=p+1
            workSheet.write(p,1,st.cell(row_index,0).value)
            workSheet.write(p,2,st.cell(row_index,1).value)
            workSheet.write(p,3,st.cell(row_index,2).value)
            workSheet.write(p,4,st.cell(row_index,3).value)
            workSheet.write(p,5,st.cell(row_index,4).value)
            
            workSheet.write(p,6,st.cell(row_index,5).value)
            workSheet.write(p,7,st.cell(row_index,6).value)
            workSheet.write(p,8,st.cell(row_index,7).value)
            workSheet.write(p,9,st.cell(row_index,8).value)
            
            workSheet.write(p,10,st.cell(row_index,9).value)
            workSheet.write(p,11,st.cell(row_index,10).value)
            workSheet.write(p,12,st.cell(row_index,11).value)
            workSheet.write(p,13,st.cell(row_index,12).value)
            
            workSheet.write(p,14,st.cell(row_index,13).value)
            workSheet.write(p,15,st.cell(row_index,14).value)
            workSheet.write(p,16,st.cell(row_index,15).value)
            workSheet.write(p,19,st.cell(row_index,16).value)
            
            workSheet.write(p,20,st.cell(row_index,17).value)
            workSheet.write(p,21,st.cell(row_index,18).value)
            workSheet.write(p,22,st.cell(row_index,19).value)
            workSheet.write(p,23,st.cell(row_index,20).value)
            

    workbook.save(common_path+path+'/错敏词.xls') 
    p=0
    




    







